#!/bin/bash

. common.sh


echo "ORC"
ORC=0.4.10

cd $SRC
curl -O -C - http://code.entropywave.com/download/orc/orc-$ORC.tar.gz
tar xvzf orc-$ORC.tar.gz 
cd orc-$ORC || exit 2
./configure --prefix=${PREFIX} --enable-shared=no --enable-static=yes || exit 2
make || exit 2
make install || exit 2


export SRC=/opt/local/src/
export PREFIX=/usr/local
export PATH=${PREFIX}/lib:${PREFIX}/bin:${PATH}
export LD_LIBRARY_PATH=${PREFIX}/lib:${LD_LIBRARY_PATH}
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig/:${PKG_CONFIG_PATH}
export DYLD_LIBRARY_PATH=/usr/local/lib:${DYLD_LIBRARY_PATH}

mv /usr/local/lib/liborc-0.4.a /usr/local/lib/liborc-$ORC.a
mv /usr/local/lib/liborc-0.4.la /usr/local/lib/liborc-$ORC.la

ldconfig

VERSION=1.0.10

echo "SCHROEDINGER"
cd $SRC
curl -O -C - http://diracvideo.org/download/schroedinger/schroedinger-$VERSION.tar.gz
tar xvzf schroedinger-$VERSION.tar.gz
cd schroedinger-$VERSION
./configure --help > /tmp/configure-schroedinger.txt
echo "Running command : ./configure --prefix=${PREFIX} --enable-shared=no --enable-static=yes "
./configure --prefix=${PREFIX} --enable-shared=no --enable-static=yes || ERROR=1
echo
echo "Running command : make"
make || ERROR=1
echo "Running command : make install"
make install || ERROR=1

cd $SRC
cd orc-$ORC || exit 2
make uninstall
rm -rf /usr/local/lib/liborc*

if [ "$ERROR" = "1" ]
then
    echo "Error during compilation of schroedinger-$VERSION"
    exit 2
fi

exit 0

